<template>
  <mycomments :gameid="gameid"/>
  <template v-for="item in commentinfo">
    <comments :commentsinfo="item"/>
  </template>
</template>

<script>
import {getcommentsbyid} from "../../api/getdata";
import comments from "./comments/comment.vue";
import mycomments from "./comments/mycomments.vue";
export default {
  components: {
    comments,
    mycomments
  },
  data(){
    return {
      commentinfo:[]
    }
  },
  props:{
    gameid:{
      type: Number,
      default: 5
    }
  },
  created() {
    console.log(this.gameid)
    this.getdata()
  },
  methods:{
    async getdata() {
      const params = {
        gameid: this.gameid
      }
      this.commentinfo = await new Promise(((resolve, reject) => {
        getcommentsbyid(params).then(res => {
          resolve(res.data)
        })
      }))
      console.log(this.commentinfo)
    }
  }
}
</script>

<style scoped>

</style>
